package com.feng.eduorder.controller;


import com.feng.commonutils.R;
import com.feng.eduorder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author fengge
 * @since 2023-03-30
 */
@RestController
@RequestMapping("/eduorder/order")
@CrossOrigin
public class OrderController {
    @Autowired
    private OrderService orderService;
    //创建订单信息
    @PostMapping("createOrder/{courseId}")
    public R saveOrder(@PathVariable String courseId,HttpServletRequest request){
        return orderService.saveOrder(courseId,request);
    }
    //根据订单id查订单信息
    @GetMapping("getOrderInfo/{orderId}")
    public R getOrderInfo(@PathVariable String orderId){
        return orderService.getOrderInfo(orderId);
    }
    //判断用户是否已经购买过该课程
    @GetMapping("getCourseBuy/{courseId}/{memberId}")
    public Boolean getCourseBuy(@PathVariable String courseId,@PathVariable String memberId){
        return orderService.getCourseBuy(courseId,memberId);
    }

}

